n=int(input())
heights=list(map(int,input().split()))

result=0

for i in range(0,n):
    left=i-1
    right=i+1
    while left>=0:
        if heights[left]<heights[i]:
            break
        left-=1;
    left+=1

    while right<n:
        if heights[right]<heights[i]:
            break
        right+=1
    right-=1

    now=(right-left+1)*heights[i]
    result=max(now,result)

print(result)

